<template>
  <div id="content">
    <van-config-provider :theme="theme"><router-view /></van-config-provider>
  </div>
</template>

<script>
import { ref } from "vue";
import { showToast } from "vant";
import store from "@/store";

export default {
  setup() {
    const DEFAULT_TITLE = "校园贴吧";
    const title = ref(DEFAULT_TITLE);
    const theme = ref("light");
    const offset = ref({ x: 300, y: 600 });

    /**
     * 根据路由切换标题
     */

    const ChangeTheme = () => {
      if (theme.value === "light") {
        theme.value = "dark";
      } else {
        theme.value = "light";
      }
    };

    const onOffsetChange = (offset) => {
      showToast("请放下我（>-<)");
    };

    const show = ref(store.state.showpopupbasic);

    if (show.value === true) {
      showToast({
        duration: 3000,
        message: "严禁发布恶意言论,不得私自发布广告",
      });
    }
    return {
      theme,
      title,
      offset,
      ChangeTheme,
      onOffsetChange,
    };
  },
};
</script>

<style scoped>
#content {
  padding-bottom: 50px;
}
</style>
